package net.tp.algo.graph;

import java.util.LinkedList;

/**
 *
 * <p>Directed graph.</p>
 *
 * @author Trung Phan
 */
public class Digraph extends BaseGraph {

    private int size;

    public Digraph(int order) {
        super(order);
    }

    public Digraph addEdge(int u, int w) {
        return addEdge(u, w, 1);
    }

    public Digraph addEdge(int u, int w, double weight) {
        Edge edge = new EdgeImpl(u, w, weight);

        if (nodes[u] == null) {
            nodes[u] = new LinkedList<>();
        }
        nodes[u].add(edge);

        size++;

        return this;
    }

    @Override
    public int size() {
        return size;
    }

}
